//
//  UserModel.m
//  TimeFaceV2
//
//  Created by Melvin on 10/29/14.
//  Copyright (c) 2014 TimeFace. All rights reserved.
//

#import "UserModel.h"
@implementation UserModel

- (void)encodeWithCoder:(NSCoder *)aCoder{
   
    [aCoder encodeObject:_phone forKey:@"phone"];
    [aCoder encodeObject:@(_from) forKey:@"from"];
    [aCoder encodeObject:@(_type) forKey:@"type"];
    [aCoder encodeObject:_avatar forKey:@"avavtar"];
    [aCoder encodeObject:_nickName forKey:@"nickName"];
    [aCoder encodeObject:_userId forKey:@"userId"];
}

-(instancetype)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super init]) {
        _phone = [aDecoder decodeObjectForKey:@"phone"];
        _from = [[aDecoder decodeObjectForKey:@"from"] integerValue];
        _type = [[aDecoder decodeObjectForKey:@"type"] integerValue];
        _avatar = [aDecoder decodeObjectForKey:@"nickName"];
        _userId = [aDecoder decodeObjectForKey:@"userId"];
    }
    return self;
}

- (id)copyWithZone:(NSZone *)zone {
    UserModel *userModel = [[[self class] allocWithZone:zone] init];
    userModel.phone = [self.phone copyWithZone:zone];
    userModel.from = self.from;
    userModel.type = self.type;
    userModel.avatar = [self.avatar copyWithZone:zone];
    userModel.nickName = [self.nickName copyWithZone:zone];
    userModel.userId = [self.userId copyWithZone:zone];
    
    return userModel;
}

@end
